var express = require('express');
var cookiesession = require("cookie-session");
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
  res.render("register.ejs");
});
router.use(cookiesession({
  "name":"curuser",
  "keys":["(&T0*(&^T^&R()nk"]
}))

router.post("/toregister",(req,res)=>{
let {tel,pass,pass2} = req.body;
console.log(req.body);
let errinfo = "";
if(tel == "" || pass == "" || pass2 =="")
{
   errinfo = "用户名和密码不得为空";
}
else
{
   req.session.TEL = tel;
   req.session.PASS = pass;
}
res.render("registerErr.ejs",{errinfo});
})

module.exports = router;
